<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\DLL.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LINE 2 &quot;libraries\\Win32\\System\\Win32\\DLL.hsc&quot; #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LINE 6 &quot;libraries\\Win32\\System\\Win32\\DLL.hsc&quot; #-}</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  System.Win32.DLL</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) Alastair Reid, 1997-2003</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- A collection of FFI declarations for interfacing with Win32.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.DLL</span><span>
</span><span id="line-21"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">disableThreadLibraryCalls</span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">freeLibrary</span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getModuleFileName</span><span>
</span><span id="line-24"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getModuleHandle</span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getProcAddress</span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">loadLibrary</span><span>
</span><span id="line-27"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">loadLibraryEx</span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">setDllDirectory</span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">lOAD_LIBRARY_AS_DATAFILE</span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">lOAD_WITH_ALTERED_SEARCH_PATH</span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromMaybe</span><span class="hs-special">)</span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-identifier">disableThreadLibraryCalls</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-identifier">disableThreadLibraryCalls</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-46"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;DisableThreadLibraryCalls&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_DisableThreadLibraryCalls</span><span> </span><span class="hs-identifier">hmod</span><span>
</span><span id="line-47"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h DisableThreadLibraryCalls&quot;</span><span>
</span><span id="line-48"></span><span>  </span><span class="hs-identifier">c_DisableThreadLibraryCalls</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-identifier">freeLibrary</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-identifier">freeLibrary</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-52"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;FreeLibrary&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_FreeLibrary</span><span> </span><span class="hs-identifier">hmod</span><span>
</span><span id="line-53"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h FreeLibrary&quot;</span><span>
</span><span id="line-54"></span><span>  </span><span class="hs-identifier">c_FreeLibrary</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-identifier">getModuleFileName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-57"></span><span class="hs-identifier">getModuleFileName</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-58"></span><span>  </span><span class="hs-identifier">allocaArray</span><span> </span><span class="hs-number">512</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_str</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-59"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetModuleFileName&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetModuleFileName</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-identifier">c_str</span><span> </span><span class="hs-number">512</span><span>
</span><span id="line-60"></span><span>  </span><span class="hs-identifier">peekTString</span><span> </span><span class="hs-identifier">c_str</span><span>
</span><span id="line-61"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetModuleFileNameW&quot;</span><span>
</span><span id="line-62"></span><span>  </span><span class="hs-identifier">c_GetModuleFileName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-identifier">getModuleHandle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HMODULE</span><span>
</span><span id="line-65"></span><span class="hs-identifier">getModuleHandle</span><span> </span><span class="hs-identifier">mb_name</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-66"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">mb_name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-67"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetModuleHandle&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetModuleHandle</span><span> </span><span class="hs-identifier">c_name</span><span>
</span><span id="line-68"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetModuleHandleW&quot;</span><span>
</span><span id="line-69"></span><span>  </span><span class="hs-identifier">c_GetModuleHandle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HMODULE</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Addr</span><span>
</span><span id="line-72"></span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-identifier">procname</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-73"></span><span>  </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">procname</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_procname</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-74"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;GetProcAddress&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetProcAddress</span><span> </span><span class="hs-identifier">hmod</span><span> </span><span class="hs-identifier">c_procname</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetProcAddress&quot;</span><span>
</span><span id="line-77"></span><span>  </span><span class="hs-identifier">c_GetProcAddress</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPCSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Addr</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-identifier">loadLibrary</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HINSTANCE</span><span>
</span><span id="line-80"></span><span class="hs-identifier">loadLibrary</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-81"></span><span>  </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-82"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;LoadLibrary&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_LoadLibrary</span><span> </span><span class="hs-identifier">c_name</span><span>
</span><span id="line-83"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h LoadLibraryW&quot;</span><span>
</span><span id="line-84"></span><span>  </span><span class="hs-identifier">c_LoadLibrary</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HINSTANCE</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-identifier">lOAD_LIBRARY_AS_DATAFILE</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span>
</span><span id="line-89"></span><span class="hs-identifier">lOAD_LIBRARY_AS_DATAFILE</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-90"></span><span class="hs-identifier">lOAD_WITH_ALTERED_SEARCH_PATH</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span>
</span><span id="line-91"></span><span class="hs-identifier">lOAD_WITH_ALTERED_SEARCH_PATH</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-pragma">{-# LINE 92 &quot;libraries\\Win32\\System\\Win32\\DLL.hsc&quot; #-}</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-identifier">loadLibraryEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HINSTANCE</span><span>
</span><span id="line-94"></span><span class="hs-identifier">loadLibraryEx</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-95"></span><span>  </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-string">&quot;LoadLibraryEx&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_LoadLibraryEx</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-identifier">flags</span><span>
</span><span id="line-97"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h LoadLibraryExW&quot;</span><span>
</span><span id="line-98"></span><span>  </span><span class="hs-identifier">c_LoadLibraryEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LoadLibraryFlags</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">HINSTANCE</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-identifier">setDllDirectory</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span class="hs-identifier">setDllDirectory</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-102"></span><span>  </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-103"></span><span>  </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">unwords</span><span> </span><span class="hs-special">[</span><span class="hs-string">&quot;SetDllDirectory&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">fromMaybe</span><span> </span><span class="hs-string">&quot;NULL&quot;</span><span> </span><span class="hs-identifier">name</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetDllDirectory</span><span> </span><span class="hs-identifier">c_name</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetDllDirectoryW&quot;</span><span>
</span><span id="line-106"></span><span>  </span><span class="hs-identifier">c_SetDllDirectory</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-107"></span></pre></body></html>